﻿Imports System.Linq.Expressions
Imports System.Text.RegularExpressions
Imports System.Collections.ObjectModel

'http://ufcpp.net/study/csharp/sp3_iqueryable.html

Namespace Load

    ''' <summary>
    ''' 一括クエリープロバイダー
    ''' </summary>
    ''' <remarks></remarks>
    Public Class BatchQueryProvider
        Inherits QueryProviderBase

        ''' <summary>
        ''' コンストラクタ
        ''' </summary>
        ''' <param name="r">モデルローダー</param>
        ''' <remarks></remarks>
        Public Sub New(r As ModelLoader)
            _loader = r
            _canLeftJoin = r.WorkCanLeftJoin
        End Sub

        Private _canLeftJoin As Boolean
        ''' <summary>
        ''' 外部結合の可否を示します
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property CanLeftJoin() As Boolean
            Get
                Return _canLeftJoin
            End Get
        End Property

        ''' <summary>
        ''' 読み込み定義を作成します
        ''' </summary>
        ''' <param name="t"></param>
        ''' <param name="q"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Protected Friend Overrides Function CreateRootTableAlias(t As System.Type, q As IQuery) As RootTableAlias
            Dim rt As RootTableAlias = MyBase.CreateRootTableAlias(t, q)

            rt.ParameterPrefix = Me.Loader.ParameterPrefix
            rt.LimitLevel = Me.Loader.WorkCascadeLevel
            rt.CanLeftJoin = Me.CanLeftJoin
            rt.IgnoreProperty = Me.Loader.MappingIgnoreProperty

            Return rt
        End Function

        ''' <summary>
        ''' 読み込み完了時イベント
        ''' </summary>
        ''' <param name="lst"></param>
        ''' <param name="t"></param>
        ''' <param name="q"></param>
        ''' <remarks></remarks>
        Protected Friend Overrides Sub OnLoaded(lst As System.Collections.IList, t As System.Type, q As IQuery)
            'なにもしない
            Return
        End Sub

    End Class

End Namespace
